package com.beiding.hotcode;

class RealPackage implements MyPackage {

    private String name;

    RealPackage(String name) {
        this.name = name;
    }

    @Override
    public MyClass getMyClassBySimpleName(String name) {
        return getMyClass(this.name + "." + name);
    }

    @Override
    public MyClass getMyClass(String name) {
        if (!name.startsWith(this.name + ".")) {
            throw new RuntimeException("无法获取");
        }
        try {
            return new RealClass(Class.forName(name));
        } catch (Exception e) {
            throw new RuntimeException(e);
        }
    }
}
